const path = require('path')

const htmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin')

module.exports = {
    mode: 'none',
    entry: path.join(__dirname, './src/main.js'),
    output: {
      filename: '[name].bundle.js',
      path: path.join(__dirname, './dist')
    },
    plugins: [
        new htmlWebpackPlugin({ // 创建一个 在 内存中 生成 html 页面的插件
          template: path.join(__dirname,'./src/index.html'),
          filename: 'index.html'
        }),
        new VueLoaderPlugin()
    ],
    module: {
        rules:[
            // css less scss样式
            {test:/\.css$/,use: ['style-loader','css-loader']},
            {test:/\.scss$/,use: ['style-loader','css-loader','sass-loader']},

            // 处理 vue 文件
            {test:/\.vue$/, use: 'vue-loader'},

            // 处理 图片 文字库
            {test:/\.ttf$/, use: 'url-loader'},
            {test:/\.(img|png|jpg)$/, use: 'url-loader'},
            // babel
            {
              test: /\.js$/,
              exclude: /node_modules/, 
              loader: "babel-loader",
              options:{
                presets:["env"]
              }
            }
        ]
    },
          resolve: {
            alias: {
              "vue$": "vue/dist/vue.js"
            }
          }
}